package io.renren.modules.sys.controller;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.entity.HumanResourcEntity;
import io.renren.modules.sys.service.HumanResourcService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author zyj
 * @email 740916741@qq.com
 * @date 2019-01-11 11:08:27
 */
@RestController
@RequestMapping("sys/humanresourc")
public class HumanResourcController {
    @Autowired
    private HumanResourcService humanResourcService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("humanresourc:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = humanResourcService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("humanresourc:info")
    public R info(@PathVariable("id") Integer id){
			HumanResourcEntity humanResourc = humanResourcService.selectById(id);

        return R.ok().put("humanResourc", humanResourc);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("humanresourc:save")
    public R save(@RequestBody HumanResourcEntity humanResourc){
            humanResourc.setCreateTime(new Date());
			humanResourcService.insert(humanResourc);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("humanresourc:update")
    public R update(@RequestBody HumanResourcEntity humanResourc){
			humanResourcService.updateById(humanResourc);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("humanresourc:delete")
    public R delete(@RequestBody Integer[] ids){
			humanResourcService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
